package com.iflytek.vueapi.controller;

import com.iflytek.vueapi.pojo.Emp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@CrossOrigin
@RestController
public class EmpController {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @GetMapping("/getAllEmp")
    public List<Emp> getAllEmp() {
        List<Emp> empList = jdbcTemplate.query("select * from emp", new BeanPropertyRowMapper<>(Emp.class));
        return empList;
    }
}
